#pragma once
#include "audio_output.h"
#include "audio_sound.h"
#include <vector>
#include <memory>

namespace krryn{
namespace audio{
	class mixer{
	public:
		typedef std::auto_ptr<mixer> ptr;

		mixer(output::ptr a_Output);
		~mixer();

		float volume();
		int buffer_duration();
		void set_volume(float a_Volume);
		void set_buffer_duration(int a_MilliSeconds);

		void play(input::ptr a_Source);
		void update();
	private:
		typedef std::vector<input::ptr> source_list_t;

		sample::ptr resample(sample::ptr a_Input);
		void mix(sample::ptr a_Sample, sample::ptr *a_Result);

		source_list_t m_Active;
		output::ptr m_Output;
		float m_MasterVolume;
		int m_BufferDuration;
	};
}
}
